import java.util.Arrays;


public class javademo {
    public static void main(String[] args) {
        int[][]array1=new int[2][3];
        int[][]array2=new int[][]{{1,2,3},{4,5,6}};
        int[][]array3={{1,2,3},{4,5,6}};
        int[][]array4=new int[2][];
    }

    public static int[] copyOF(int[]array){
        int[]copy=new int[array.length];
        for (int i = 0; i < array.length; i++) {
            copy[i]=array[i];
        }
        return copy;
        //System.out.println(Arrays.toString(copy));
    }
    public static void fu(int[]array){
        for (int i = 0; i < array.length; i++) {
            array[i]=i+1;
        }
    }

    public static void main5(String[] args) {
        int[]array={1,5,9,7,8};
        int[]res=copyOF(array);
        System.out.println(Arrays.toString(res));
    }

    public static double avg(int[]array){
        int mount=0;
        for (int i = 0; i < array.length; i++) {
            mount+=array[i];
        }
        return 1.0*mount/(array.length);
    }
    public static int sum(int[]array){
        int mount=0;
        for (int i = 0; i < array.length; i++) {
            mount+=array[i];
        }
        return mount;
    }
    public static void main4(String[] args) {
        int[]array={1,2,3,4};
        System.out.println(avg(array));
    }

    public static int jie(int n){
        if(n*(n-1)==0){
            return(n);
        }
        int sum=n*jie(n-1);
        return sum;
    }

    public static int ret(int n){
        if(n-1<0){
            return n;
        }
        int sum=n+ret(n-1);
        return sum;
    }


    public static void print(int n){
        if(n<=9){
            System.out.println(n);
            return;
        }
        print(n/10);
        System.out.println(n%10);
    }

    public static int nsum(int n){
        if(n<0){
            System.out.println("输入错误");
            return -1;
        }
        if(n<=9){
            return n;
        }
        int sum=n%10+nsum(n/10);
        return sum;
    }

    public static int fac(int n){
        if(n==1||n==2){
            return 1;
        }
        int sum=fac(n-1)+fac(n-2);
        return sum;
    }

    public static int max(int a,int b){
        return (a>b?a:b);
    }
    public static double max(double a,double b){
        return (a>b?a:b);
    }
    public static double max(double a,double b,int c){
        double index=0.0;
        index= (a>b?a:b);
        return (index>b?index:b);
    }
    public static void main2(String[] args) {
        int a=1,b=2;
        double c=1.5,d=1.6;
        //System.out.println("两整数比较 "+max(a,b));
        //System.out.println("两浮点数比较 "+max(c,d));
        //System.out.println("两浮点数与一整数比较 "+max(c,d,a));
        //System.out.println(fac(4));
       // int i=nsum(1234);
        //System.out.println(i);
        //print(123);
        System.out.println(jie(5));
    }





    /**
     *
     * @param //该函数模拟实现了将一个整型数组以字符串形式打印出来
     */
    public static void fac1(int[]array){
        String str="[";
        for (int i = 0; i < array.length; i++) {
            if(i== array.length-1){
                str=str+array[i]+"]";
            }else{
                str=str+array[i]+",";
            }
        }
        System.out.println(str);
    }

    /**
     *
     * @param //该函数调用了Arrays包的方法实现了打印数组元素
     */
    public static void print(int[]array){
        String str= Arrays.toString(array);
        System.out.println("该数组如下"+str);
    }

    /**
     *
     * @param //测试引用类型（数组的本质）
     */

    public static int[] modify(int[]array){
        int[]a=new int[]{12};
        int[] arr;
        arr=new int[] {11,22,33,44,55};
        array[0]=666;
        arr=array;

        return a;
    }

    /**
     *
     * @param args//遍历打印数组
     */
    public static void printb(int[]array){
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
    }
    public static void printb1(int[]array){
        for (int x:array) {
            System.out.println(x+" ");
        }
    }

    /**
     *
     * @param args//for循环拷贝数组
     */
    public static int[] fcopy(int[]array){
                int[]copy=new int[array.length];
                for (int i = 0; i < array.length; i++) {
                    copy[i]=array[i];
        }
                return copy;
        //System.out.println(Arrays.toString(copy));
    }

    /**
     *
     * @param args//用Arrays包类的函数copyOf拷贝数组
     */
    public static void ccopy(int[]array){
        int[]copy=Arrays.copyOf(array,array.length+1);
        System.out.println(Arrays.toString(copy));
    }

    /**
     * 第3种拷贝方式 System.arraycopy
     * @param args
     */
    public static void acopy(int[]array){
        int[]copy=new int[array.length];
        System.arraycopy(array,0,copy,0,array.length);
        System.out.println(Arrays.toString(copy));
    }
    public static void main6(String[] args) {
        int []array={1,2,3,4,5};
        int []array2={10,20,30,40,50};
        fac1(array);
        //print(array);
        //int[]arr1=modify(array);
        //System.out.println(Arrays.toString(arr1));
        //printb(array2);
        //printb1(array2);
       // fcopy(array2);
       // ccopy(array);
        //acopy(array2);
    }
}
